2008年09月30日
川俣晶の縁側ソフトウェア技術雑記 total 9719 count

特定バージョンのMinGWのgccでcp932のソースがコンパイルできない

Written By: 川俣 晶連絡先

 特定バージョンのMinGWのgccでcp932のソースがコンパイルできない現象に遭遇したので、分かったことだけメモ。

現象 §

 通常"表"のようなシフトJIS(cp932)の文字を含むソースは、以下のようなオプションを指定することでコンパイルできる。

gcc -finput-charset=cp932 -fexec-charset=cp932 test.c

 しかし、特定バージョンのMinGWのgccではコンパイルできない。

 MinGW 5.1.4としてインストールした場合でも内部で使用するファイルのバージョンの相違によって問題が出る場合と出ない場合がある。

エラーの例 §

cc1.exe: no iconv implementation, cannot convert from cp932 to UTF-8

cc1.exe: no iconv implementation, cannot convert from UTF-8 to cp932

test.c:1:19: no iconv implementation, cannot convert from cp932 to UTF-8

In file included from test.c:1:

c:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:19:20: no icon

v implementation, cannot convert from cp932 to UTF-8

c:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:26:20: no icon

v implementation, cannot convert from cp932 to UTF-8

c:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:28:20: no icon

v implementation, cannot convert from cp932 to UTF-8

c:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/stdio.h:414:23: no ico

nv implementation, cannot convert from cp932 to UTF-8

In file included from c:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/

stdio.h:414,

from test.c:1:

c:/mingw/bin/../lib/gcc/mingw32/3.4.5/../../../../include/sys/types.h:21:20: no

iconv implementation, cannot convert from cp932 to UTF-8

確認事項 §

 標準的なインストールでc:\MinGW\installed.iniに生成されるファイルを見たとき。

OKだった環境 §

[components]

runtime=mingw-runtime-3.14.tar.gz

w32api=w32api-3.11.tar.gz

binutils=binutils-2.17.50-20060824-1.tar.gz

core=gcc-core-3.4.5-20060117-1.tar.gz

NGだった環境 §

[components]

runtime=mingw-runtime-3.14.tar.gz

w32api=w32api-3.11.tar.gz

binutils=binutils-2.17.50-20060824-1.tar.gz

core=gcc-core-3.4.5-20060117-3.tar.gz

考察 §

 gcc-coreのバージョンの相違によってcp932対応(より正確には文字コードの変換対応)が有効ではなくなっている模様。